package com.infra.micro.quartz.fallback;

import com.infra.micro.quartz.model.req.QueryQuartzJobReq;
import com.infra.micro.quartz.model.vo.QuartzJobVO;
import com.infra.common.resp.Page;
import com.infra.common.resp.Response;
import com.infra.micro.quartz.api.QuartzJobApi;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;

@Component
public class QuartzJobApiFallback implements FallbackFactory<QuartzJobApi> {
    @Override
    public QuartzJobApi create(Throwable cause) {
        return new QuartzJobApi() {
            @Override
            public Response<Boolean> create(@RequestBody QuartzJobVO model) {
                return Response.error("服务器错误，请联系相关服务负责人");
            }

            @Override
            public Response<Boolean> update(@PathVariable("jobId") Long jobId, @RequestBody QuartzJobVO model) {
                return Response.error("服务器错误，请联系相关服务负责人");
            }

            @Override
            public Response<QuartzJobVO> queryById(@PathVariable("jobId") Long jobId) {
                return Response.error("服务器错误，请联系相关服务负责人");
            }

            @Override
            public Response<Boolean> deleteById(@PathVariable("jobId") Long jobId) {
                return Response.error("服务器错误，请联系相关服务负责人");
            }

            @Override
            public Response<Page<QuartzJobVO>> queryListByPage(QueryQuartzJobReq req) {
                return Response.error("服务器错误，请联系相关服务负责人");
            }
        };
    }
}

